// To parse this JSON data, do
//
//     final tagModel = tagModelFromJson(jsonString);

import 'dart:convert';

TagModel tagModelFromJson(String str) => TagModel.fromJson(json.decode(str));

String tagModelToJson(TagModel data) => json.encode(data.toJson());

class TagListModel {
  List<TagModel> list;
  TagListModel(this.list);

  factory TagListModel.fromJson(List<dynamic> list) {
    // 调用自身构造方法传值并返回
    return TagListModel(
      list.map((listItem) => TagModel.fromJson(listItem)).toList(),
    );
  }
}

class TagModel {
  TagModel({
    this.id,
    this.name,
    this.createUserId,
    this.fansCount,
    this.artistId,
    this.createTime,
    this.updateTime,
  });

  int id;
  String name;
  int createUserId;
  int fansCount;
  int artistId;
  DateTime createTime;
  DateTime updateTime;

  factory TagModel.fromJson(Map<String, dynamic> json) => TagModel(
        id: json["id"],
        name: json["name"],
        createUserId: json["createUserId"],
        fansCount: json["fansCount"],
        artistId: json["artistId"],
        createTime: DateTime.parse(json["createTime"]),
        updateTime: DateTime.parse(json["updateTime"]),
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "createUserId": createUserId,
        "fansCount": fansCount,
        "artistId": artistId,
        "createTime": createTime.toIso8601String(),
        "updateTime": updateTime.toIso8601String(),
      };
}
